home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 15423 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.3 KB

  1. Path: mail2news.demon.co.uk!genesis.demon.co.uk
  2. From: Lawrence Kirby <fred@genesis.demon.co.uk>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: ===  **ptr  QUES  ===
  5. Date: Thu, 18 Apr 96 22:03:48 GMT
  6. Organization: none
  7. Message-ID: <829865028snz@genesis.demon.co.uk>
  8. References: <31767207.167E@cell.co.uk>
  9. Reply-To: fred@genesis.demon.co.uk
  10. X-NNTP-Posting-Host: genesis.demon.co.uk
  11. X-Newsreader: Demon Internet Simple News v1.27
  12. X-Mail2News-Path: genesis.demon.co.uk
  13.  
  14. In article <31767207.167E@cell.co.uk> kai@cell.co.uk "Kai Chan" writes:
  15.  
  16. >Hi,
  17. >        I've got the following code fragment. Question I've got concerns
  18. >passing the pointer to a pointer to func1, and that is: which is
  19. >correct?
  20. >
  21. >blar...
  22. >blar...
  23. >
  24. >main()
  25. >{
  26. >        some_type1      **ptr;
  27. >
  28. >        func1(ptr);     /* is this right? */
  29.  
  30. This is the one that passes a value of the correct type. However when you
  31. use the value of a variable in C that variable must be set to a well-defined
  32. value. Here ptr is uninitialised so passing its value as a function argument
  33. is illegal. So you need to set it to something first, typically a pointer to
  34. a char * object/variable or element of an array f char * that you want func1
  35. to access or modify.
  36.  
  37. -- 
  38. -----------------------------------------
  39. Lawrence Kirby | fred@genesis.demon.co.uk
  40. Wilts, England | 70734.126@compuserve.com
  41. -----------------------------------------
  42.